/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package conversation;

import example.model.Database;
import example.model.Person;
import example.model.PersonMapper;
import picounit.Should;
import picounit.Test;

public class ImperativePersonMapperTest implements Test {
	private final PersonMapper personMapper;
	private final Database database;

	public ImperativePersonMapperTest(Database mockDatabase) {
		this.personMapper = new PersonMapper(mockDatabase);

		this.database = mockDatabase;
	}

	public void shouldInsertARowIntoThePeopleTableWhenSavingAPerson(Should should) {
		should.expectTo("Use a Database to save a Person")
			.byCalling(database.insert("insert into people (name) values('Fred Dibner')"))
			.andReturning(true);

		should.expectAboveWhenTheFollowingOccurs();

		Person fred = new Person("Fred Dibner");
		personMapper.save(fred);
	}
}